package com.wang.exception_hw2;

public class Account {
    private double balance;//余额

    public Account() {
    }

    public Account(double balance) {
        this.balance = balance;
    }

    public double getBalance() {
        return balance;
    }

    /**
     * 存钱
     */
    public void deposit(double amount){
        balance += amount;
    }

    /**
     * 取钱
     */
    public void withdraw(double amount) throws OverdraftException {
        if (balance < amount){
            throw new OverdraftException("余额不足！",amount - balance);
        }
        balance -= amount;
    }
}
